import 'package:flutter/material.dart';
import 'package:flutter_demo/redux/bo/cm_frame_work.dart';
import 'package:flutter_demo/ui/page/home/user_profile_view.dart';
import 'package:get/get.dart';
import 'package:get/state_manager.dart';

import 'case_view.dart';

class HomePage extends CMPage {
  HomePage({super.key});

  var count = 0.obs;

  var size = const Size(1, 1).obs;

  // final TabController tabController = TabController(length: 3, vsync: this);

  @override
  Widget build(BuildContext context) {
    return DefaultTabController(
      initialIndex: 0,
      length: 4,
      child: Scaffold(
        appBar: AppBar(
          title: const Text('TabBar Sample'),
          bottom: const TabBar(
            tabs: <Widget>[
              Tab(
                text : "直播",
                icon: Icon(Icons.cloud_outlined),
              ),
              Tab(
                text : "案例",
                icon: Icon(Icons.cases_outlined),
              ),
              Tab(
                text : "购买",
                icon: Icon(Icons.shop_outlined),
              ),
              Tab(
                text : "我的",
                icon: Icon(Icons.dark_mode_outlined),
              ),
            ],
          ),
        ),
        body: TabBarView(
          children: <Widget>[
            Center(
              child: Column(
                children: [
                  OutlinedButton(
                      onPressed: () {
                        count++;
                        size.value =
                            Size(size.value.width + 1, size.value.height + 1);
                      },
                      child:
                          Obx(() => Text("$count It's cloudy here ${size}"))),
                  OutlinedButton(
                    onPressed: () {
                      // store.api.demo();
                      store.api.loginWith(mobile: "18615796737", pwd: "111111").then((value) => {
                        // print("loginWithPwd loginWithPwd loginWithPwd")
                        print(value.toString())
                      });
                    },
                    child: Text("login"),
                  )
                ],
              ),
            ),
            Center(
              child: CMCaseView(),
            ),
            Center(
              child: Text("It's sunny here"),
            ),
            Center(
              child: CMUserProfileView(),
            ),
          ],
        ),
      ),
    );
  }
}
